<extend name="./Apps/Home/View/default/shops/layout.html" />
<block name="content">
<style>

</style>
<script>
    function editUser(){
        var params = {};
        params.userId = $("#userId").val();
        params.loginName = $.trim($('#loginName').val());
        params.userQQ = $.trim($('#userQQ').val());
        params.userPhone = $.trim($('#userPhone').val());
        params.userEmail = $.trim($('#userEmail').val());
        params.userSex = $('input:radio[name="userSex"]:checked').val();
        params.userPhoto =  $.trim($('#userPhoto').val());
        params.loginPwd =   $.trim($('#loginPwd').val());
        params.reUserPwd =   $.trim($('#reUserPwd').val());
        var ll = layer.load('数据处理中，请稍候...');
        $.post(Think.U('Home/Shops/addWaiter'),params,function(data,textStatus){
            layer.close(ll);
            var json = WST.toJson(data);
            if(json.status=='1'){
                WST.msg('操作成功!', {icon: 1},function(){
                    location.href= location.href;
                });
            }else if(json.status=='-2'){
                WST.msg('用户手机已存在!', {icon: 5});
            }else if(json.status=='-3'){
                WST.msg('用户邮箱已存在!', {icon: 5});
            }else{
                WST.msg('修改用户资料失败!', {icon: 5});
            }
        });
    }
$(function () {
    $("#addWaiter").click(function(){
        editUser();
    });
//	   $.formValidator.initConfig({
//		   theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,onSuccess:function(){
//				   editUser();
//			       return false;
//			},onError:function(msg){
//		}});
//	   $("#loginName").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:2,max:20,onError:"用户昵称长度为6到20位"});
//	   $("#userPhone").inputValidator({min:0,max:25,onError:"你输入的手机号码非法,请确认"}).regexValidator({
//			regExp:"mobile",dataType:"enum",onError:"手机号码格式错误"
//		}).ajaxValidator({
//			dataType : "json",
//			async : true,
//			url : Think.U('Home/Users/checkLoginKey'),
//			success : function(data){
//				var json = WST.toJson(data);
//	            if( json.status == "1" ) {
//	                return true;
//				} else {
//	                return false;
//				}
//				return "该手机号码已被使用";
//			},
//			buttons: $("#dosubmit"),
//			onError : "该手机号码已存在。",
//			onWait : "请稍候..."
//		}).defaultPassed().unFormValidator(true);
//		$("#userEmail").inputValidator({min:0,max:25,onError:"你输入的邮箱长度非法,请确认"}).regexValidator({
//		       regExp:"email",dataType:"enum",onError:"邮箱格式错误"
//			}).ajaxValidator({
//				dataType : "json",
//				async : true,
//				url : Think.U('Home/Users/checkLoginKey'),
//				success : function(data){
//					var json = WST.toJson(data);
//		            if( json.status == "1" ) {
//		                return true;
//					} else {
//		                return false;
//					}
//					return "该电子邮箱已被使用";
//				},
//				buttons: $("#dosubmit"),
//				onError : "该邮箱已存在。",
//				onWait : "请稍候..."
//			}).defaultPassed().unFormValidator(true);
//		$("#userPhone").blur(function(){
//			  if($("#userPhone").val()==''){
//				  $("#userPhone").unFormValidator(true);
//			  }else{
//				  $("#userPhone").unFormValidator(false);
//			  }
//		});
//		$("#userEmail").blur(function(){
//			  if($("#userEmail").val()==''){
//				  $("#userEmail").unFormValidator(true);
//			  }else{
//				  $("#userEmail").unFormValidator(false);
//			  }
//		});
		var uploading = null;
		uploadFile({
		    server:Think.U('Home/users/uploadPic'),pick:'#filePicker',
		    formData: {dir:'users'},
		    accept: {
	  	        title: 'Images',
	  	        extensions: 'gif,jpg,jpeg,png',
	  	        mimeTypes: 'image/*'
	  	    },
		    callback:function(f){
		    	layer.close(uploading);
		    	var json = WST.toJson(f);
		    	$('#userPhotoPreview').attr('src',WST.DOMAIN+"/"+json.file.savepath+json.file.savethumbname);
		    	$('#userPhoto').val(json.file.savepath+json.file.savename);
		    	$('#userPhotoPreview').show();
			},
			progress:function(rate){
			    uploading = WST.msg('正在上传图片，请稍后...');
			}
		});
});
</script>
	
   	<div class="wst-body"> 
       <div class='wst-page-header'>商家中心 > 管理服务员</div>
       <div class='wst-page-content' style="position:relative;">
       <form name="myform" method="post" id="myform" autocomplete="off">
        <table class="table table-hover table-striped table-bordered wst-form" style='margin-top:10px;'>

           <tr>
               <notempty name="userId"><input type="hidden" id="userId" name="userId" value="{$userId}"></notempty>
             <th align='right' width="80">昵称 <font color='red'>*</font>：</th>
             <td>
             <input type='text' id='loginName' name='loginName'  value="{$user['loginName']}"/>
             </td>

             <td rowspan='5'>
                <div style="margin-bottom: 10px;">
		           <img id='userPhotoPreview' class='lazyImg' data-original='<if condition="$user['userPhoto'] =='' ">__ROOT__/{$CONF['goodsImg']}<else/>{:WSTImgPath($user['userPhoto'])}</if>'  height='100'/><br/>
	            </div>
	            <input type='hidden' id='userPhoto' class='wstipt' value='{$user["userPhoto"]}'/>
	            <div id="filePicker" style='margin-left:0px;float:left'>上传服务员头像</div>
             	<div style="clear: both;">图片大小:150 x 150 (px)，格式为 gif, jpg, jpeg, png</div>
             </td>
           </tr>
            <tr>
                <th align='right' width="80">密码 <font color='red'>*</font>：</th>
                <td>
                    <input type='password' id='loginPwd' name='loginPwd' />
                </td>
            </tr>

            <tr>
                <th align='right' width="80">确认密码 <font color='red'>*</font>：</th>
                <td>
                    <input type='password' id='reUserPwd' name='reUserPwd' />
                </td>
            </tr>
           <tr>
             <th align='right'>性别 <font color='red'>*</font>：</th>
             <td>
                 <label><input type='radio' name='userSex' value="1" <if condition="$user['userSex'] eq 1">checked</if>/>男</label>
                 <label><input type='radio' name='userSex' value="2" <if condition="$user['userSex'] eq 2">checked</if>/>女</label>
                 <label><input type='radio' name='userSex' value="3" <if condition="$user['userSex'] eq 3">checked</if>/>保密</label>
             </td>
           </tr>
            <tr>
             <th align='right'>服务员QQ ：</th>
             <td>
             <input type='text' id='userQQ' name='userQQ'  value="{$user['userQQ']}" />
             </td>
           </tr>
           <tr>
             <th align='right'>手机：</th>
             <td>
             <input type='text' id='userPhone' name='userPhone' value="{$user['userPhone']}"  maxlength="11"/>
             </td>
           </tr>
           <tr>
             <th align='right'>邮箱：</th>
             <td>
             <input type='text' id='userEmail' name='userEmail' value="{$user['userEmail']}" maxlength="25" style='width:250px'/>
             </td>
           </tr>
           <tr>
             <td colspan='3' style='padding-left:250px;height:100px;'>
                 <button class='wst-btn-query' id="addWaiter" type="button">保&nbsp;存</button>
                 <button class='wst-btn-query' type="reset">重&nbsp;置</button>
             </td>
           </tr>
           
        </table>
       </form>
       </div>
   </div>
</block>  
